
{% load static %}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>登入-职位推荐系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="{% static "layuiadmin/layui/css/layui.css" %}" media="all">
  <link rel="stylesheet" href="{% static "layuiadmin/style/admin.css" %}" media="all">
  <link rel="stylesheet" href="{% static "layuiadmin/style/login.css" %}" media="all">
</head>
<body background="/static/layuiadmin/bg.png" style="background-size: cover; background-position: center;">

  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>欢迎登录</h2>
        <p>基于Python职位信息推荐系统</p>
      </div>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
          <input type="text" name="user" placeholder="账号id" class="layui-input">
        </div>
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
          <input type="password" name="password" placeholder="密码" class="layui-input">
        </div>
        <div class="layui-form-item" style="margin-bottom: 20px;">
          <a href="{% url "register" %}" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">还没账号？</a>
        </div>
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
        </div>
      </div>
    </div>
  </div>

  <script src="{% static "layuiadmin/layui/layui.js" %}"></script>
  <script>
  layui.config({
    base: '{% static "layuiadmin/" %}' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','jquery'], function(){
    var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

    //提交
    form.on('submit(LAY-user-login-submit)', function(obj){
            obj = obj.field;

            if (obj.user == '') {
                layer.msg('账号不能为空');
                return false;
            }
            if (obj.password == '') {
                layer.msg('密码不能为空');
                return false;
            }

            //请求登入接口
            $.ajax({
               type: 'POST',
               url: '/login/',
               data: obj,
               success: function (res) {
                   // 弹窗内容， 样式
                   if (res.code == 0) {
                        layer.msg(res.msg, {icon:1,time:1000});
                        setTimeout(function (){location.href="/index/";}, 1000) // 延迟重定向
                        }
                   else {
                            layer.msg(res.msg);
                            return false;
                        }
               },
               error:function(response){
                   layer.msg(response.msg);
               }
           })
    });
  });
  </script>
</body>
</html>